// MessagePack是一种高效的二进制序列化格式。它允许您像JSON一样在多个语言之间交换数据。但是，它更快并且更小。
package main

import (
	"fmt"
	"github.com/vmihailenco/msgpack"
)

type Dog struct {
	Name string
	Age  int
	Type string
}

func main() {
	var dogs []Dog
	dog := Dog{"小奶狗", 1, "田园犬"}
	dog2 := Dog{"小陆", 1, "贵宾"}
	dog3 := Dog{"小杨", 1, "二哈"}
	dogs = append(dogs, dog, dog2, dog3)
	//fmt.Println(dogs)
	// 序列化
	res, _ := msgpack.Marshal(&dogs)
	fmt.Println(string(res))

	// 反序列化
	var dogs1 []Dog
	msgpack.Unmarshal(res, &dogs1)
	fmt.Println(dogs1)
}
